import React, { Component } from 'react';
import { connect } from 'react-redux'  
import { Modal, Form, Input, Radio, TreeSelect, Select } from 'antd';
const TreeNode = TreeSelect.TreeNode;
const FormItem = Form.Item;
const RadioGroup = Radio.Group;

class CabinetGroupModal extends Component {
  constructor(props) {
    super(props);
  }

  okHandler = () => {
     const { onOk } = this.props;
     this.props.form.validateFields((err, values) => {
      if (!err) {
        onOk(values);
      }
     });
  }; 
  
  render() {

    const { children, dispatch, item, } = this.props;
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 },
    };  

    return (
      <span>
        <Modal
                maskClosable= {this.props.maskClosable}
                confirmLoading= {this.props.confirmLoading}
                title={this.props.title}
                visible={this.props.visible}
                onOk={this.okHandler}
                onCancel={this.props.onCancel}
                key={this.props.newKey}
        >
          <Form layout='horizontal' onSubmit={this.okHandler}>
            <FormItem style={{marginBottom:'0px'}}>
              {getFieldDecorator('id',{initialValue:item.id_})(
                <Input type="hidden"/>
              )}
            </FormItem>
            <FormItem
                  {...formItemLayout}
                  label="机柜组名称"
                  hasFeedback
                >
                  {
                   getFieldDecorator('name', {
                      initialValue: item.name,
                      rules: [
                        { required: true, whitespace: true, message: '请输入机柜组名称',},
                        { max:50,message: '机柜组名称不能超过50个字' },
                      ]
                   })(<Input placeholder="请输入机柜组名称"/>)
                  }
            </FormItem>
            <FormItem
                  {...formItemLayout}
                  label="备注"
                  hasFeedback
                >
                  {
                    getFieldDecorator('remark', {
                      initialValue: item.remark,
                      rules: [
                        { type: 'string', max: 100, message: '最多100个字符' }
                      ],
                    })(<Input type="textarea" rows={5} />)
                  }
            </FormItem>     
           
          </Form>
        </Modal>
      </span>
    );
  }
    
}

export default Form.create()(CabinetGroupModal)
